package com.leon.datalink.web.testcontroller;

import org.springframework.web.bind.annotation.*;

/**
 * Simple CORS Test Controller
 */
@RestController
@RequestMapping("/api/test")
@CrossOrigin(origins = "*", maxAge = 3600)
public class CorsTestController {

    @GetMapping("/hello")
    public String hello() {
        return "Hello from DataLink Backend!";
    }
    
    @PostMapping("/login")
    public String testLogin(@RequestParam("username") String username, @RequestParam("password") String password) {
        if ("admin".equals(username) && "datalink".equals(password)) {
            return "{\"status\":\"success\",\"token\":\"test-token-123\",\"message\":\"Login successful\"}";
        } else {
            return "{\"status\":\"error\",\"message\":\"Invalid credentials\"}";
        }
    }
    
    @GetMapping("/status")
    public String status() {
        return "{\"status\":\"running\",\"message\":\"DataLink backend is running successfully\"}";
    }
}
